package com.qst.web;

import com.qst.po.PageData;
import com.qst.po.Qustion;
import com.qst.po.Student;
import com.qst.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class StudentController {
    @Autowired
    private IStudentService studentService;
    @RequestMapping("tostulistbycid")
    private String tostulistbycid(int cid, HttpServletRequest request){
        request.setAttribute("cid",cid);
        return "stulistbycid";
    }
    @RequestMapping("getstulistbycid")
    @ResponseBody
    public PageData<Student> getclassqusbypagecid(int cid, int page, int limit) {
        PageData<Student> data = new PageData<Student>();

        int totalcount = studentService.getclastutalcount(cid);
        List<Student> qustions = studentService.getclastubypage(cid,page,limit);
        data.setCode(0);
        data.setMsg("");
        data.setCount(totalcount);
        data.setData(qustions);
        return data;
    }

}
